//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import Mall_campsitemBox from "../../views/mall/Mall_campsitemBox.vue"
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
        gridBody: Mall_campsitemBox,
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: { view: [], box: [], detail: [] },//扩展的按钮
    methods: {//事件扩展
        onInit () {
            this.$store.getters.data().viewPageTest = this;
            this.ck = false
            this.columns.push({
                title: '操作',
                fixed: 'right',
                width: 140,
                render: (h, { row, column, index }) => {
                    return h(
                        "div", { style: {} }, [
                        h(
                            "a", {
                            props: {},
                            style: {},
                            on: {
                                click: (e) => {
                                    this.$refs.gridBody.openModel2(row)
                                }
                            }
                        }, "团队管理"),
                        h(
                            "a", {
                            props: {},
                            style: {
                                "margin-left": "10px"
                            },
                            on: {
                                click: (e) => {
                                    this.$refs.gridBody.openModel3(row)
                                }
                            }
                        }, "营员管理"),
                    ])
                }
            })

        },
        searchAfter (result) {
            result.forEach(i => {
                if (i.campgrouping) {
                    let campgrouping = JSON.parse(i.campgrouping)
                    i.teamnum = campgrouping.length
                    i.groupnum = 0
                    let grouNUm = []
                    campgrouping.forEach(j => {
                        grouNUm.push(j.group.length)
                        function sum (arr) {
                            return arr.reduce((prev, curr)=> {
                                return prev + curr;
                            });
                        }
                        i.groupnum = sum(grouNUm)
                    })
                } else {
                    i.teamnum = 0
                    i.groupnum = 0
                }
            })
            return true;
        },
    }
};
export default extension;